from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field

from core.utils.log import mylogger


class BaseAgent(BaseModel, ABC):

    # Core attributes
    name: str = Field(..., description="Unique name of the agent")
    description: Optional[str] = Field(None, description="Optional agent description")

    class Config:
        arbitrary_types_allowed = True
        extra = "allow"  # Allow extra fields for LLM instances and managers

    def model_post_init(self, __context: Any) -> None:
        """Initialize agent after model creation."""
        mylogger.info(f"Initialized agent: {self.name}")

    @abstractmethod
    async def process(self, input_data: Dict[str, Any]) -> Any:
        """Process input data. Must be implemented by subclasses.

        Args:
            input_data: Input data to process

        Returns:
            Processed output
        """
        pass
